package com.badibadi.activity;

import com.badibadi.infos.UserInfoModel;
import com.badibadi.mytools.UserDataSet;
import com.badibadi.uniclubber.R;
import com.badibadi.uniclubber.R.layout;
import com.badibadi.uniclubber.R.menu;

import android.os.Bundle;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class ModifyTheMyDataActivity extends ModifyTheDataActivity implements OnClickListener{

	private EditText et_Data;
	private Button btn_Save;
	private int id;
	Context context;
	/**存放点击保存后返回的数据*/
    private String rel="";
    /**保存按返回键返回的数据*/
    private String resh="";
    private UserInfoModel userInfoModel;
    private UserDataSet userDataSet;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		userDataSet=new UserDataSet(ModifyTheMyDataActivity.this);
	
	}

    @Override
    protected void init() {
    	// TODO Auto-generated method stub
    	userInfoModel=new UserInfoModel();
    	userInfoModel=(UserInfoModel) getIntent().getSerializableExtra("UseInfoModel");
    	id=getIntent().getIntExtra("id",-1);
    	 String str=getIntent().getStringExtra("KEY"+id);
    	 String titlename=getIntent().getStringExtra("STR"+id);
//    	    
    	 resh=str;
		et_Data=(EditText)this.findViewById(R.id.Data_xiugai);
		btn_Save=(Button)this.findViewById(R.id.btn_Save);
		btn_Save.setOnClickListener(this);
		
		
		
		
		
		TextView title=(TextView)this.findViewById(R.id.title);
	
          this.findViewById(R.id.returnbtn).setOnClickListener(new View.OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
//				Intent intent=new Intent(ModifyTheMyDataActivity.this,MyDataActivity.class);
//				setResult(((id*100)+id), intent);
				finish();
			}
		});
        title.setText(titlename);
        et_Data.setText(str);
        
    }

    @Override
    protected void returnData() {
    	// TODO Auto-generated method stub
    	
    }
  
    @Override
    public void onClick(View v) {
    	// TODO Auto-generated method stub
    	
         switch(v.getId())
         {
         case R.id.btn_Save:
//        	 returnData(false);
        	 if(userInfoModel!=null)
         	{
         		setUserInfo();
         	}
        	Intent intent=new Intent(ModifyTheMyDataActivity.this,MyDataActivity.class);
 			setResult(((id*100)+id), intent);
 			finish();
        	 break;
         }
    }
    /**
     * 设置用户信息
     */
	private void setUserInfo() {
	// TODO Auto-generated method stub
		 switch(id)
    	 {
    	 case 1://昵称
    		 userInfoModel.setNickName(et_Data.getText().toString().trim());
    		 userDataSet.UserDataSet(userInfoModel, 0, "", false);
//    		 setResult(resultCode);
    		 break;
    	 case 4://专长介绍
    		 userInfoModel.setSpeciality(et_Data.getText().toString().trim());
    		 userDataSet.UserDataSet(userInfoModel, 0, "", false);
    		 break;
    	 case 6://座右铭
    		 userInfoModel.setMotto(et_Data.getText().toString().trim());
    		 userDataSet.UserDataSet(userInfoModel, 0, "", false);
    		 break;
    	 case 8://邮箱
    		 userInfoModel.setEmail(et_Data.getText().toString().trim());
    		 userDataSet.UserDataSet(userInfoModel, 0, "", false);
    		 break;
    	 case 10://支付宝账号
    		 userInfoModel.setAlipay(et_Data.getText().toString().trim());
    		 userDataSet.UserDataSet(userInfoModel, 0, "", false);
    		 break; 
    	 case 13://手机号码
    		 userInfoModel.setPhone(et_Data.getText().toString().trim());
    		 userDataSet.UserDataSet(userInfoModel, 0, "", false);
    		 break;
    	 case 16://最想参加的俱乐部
    		 userInfoModel.setLike_club(et_Data.getText().toString().trim());
    		 userDataSet.UserDataSet(userInfoModel, 0, "", false);
    		 break;
    	 case 17://最讨厌的俱乐部
    		 userInfoModel.setUnlike_club(et_Data.getText().toString().trim());
    		 userDataSet.UserDataSet(userInfoModel, 0, "", false);
    		 break;
    	 case 19://学历背景
    		 userInfoModel.setEducation(et_Data.getText().toString().trim());
    		 userDataSet.UserDataSet(userInfoModel, 0, "", false);
    		 break;
    	 case 20://支付宝账户名称
    		 userInfoModel.setAlipayName(et_Data.getText().toString().trim());
    		 userDataSet.UserDataSet(userInfoModel, 0, "", false);
    		 break;
    	 }
      }

	
}
